#ifndef __MAINWINDOW_H__
#define __MAINWINDOW_H__

#include <QMainWindow>
#include <QSystemTrayIcon>

#include "common/status.h"

class Friend;

class QMenu;
class QCloseEvent;
namespace Client {
	class Client;
}

namespace Ui {

class Login;
class MainWidget;

class MainWindow : public QMainWindow {
	Q_OBJECT

public:
	MainWindow(QWidget *parent = 0);
	~MainWindow();
	void createLogin();
	void createTrayIcon();
	void friendEnteredMessage(const QString &friend_);
	void friendChangedStatusMessage(const QString &friend_, Status current);
protected:
	void closeEvent(QCloseEvent *e);

private:
	void createProtocolConnects();
	bool systrayMsg;
	Client::Client *client;
	Login* login;
	MainWidget *mainWidget;
	QSystemTrayIcon *trayIcon;
	QMenu *windowMenu,*trayIconMenu;
	QAction *restoreAction;
	QAction *quitAction;
	QAction *disconnectAction;
	QAction *configAction;
	QAction *registrationAction;
	QString host;
	quint16 port;
	quint16 inactivityTime;

private slots:
	void iconActivated(QSystemTrayIcon::ActivationReason reason);
	void tryToConnect(const QString& login, const QString& password);
	void cancelConnection();
	void connected(Friend *me);
	void refused();
	void disconnected();
	void disconnect();
	void restore();
	void config();
	void registration();
	void statusChanged(Status);
	void signup(const QString &login,const QString &password);
	};

}

#endif // MAINWINDOW_H

